package com.financing.wap.dao.impl;

import com.financing.wap.common.SqlName;
import com.financing.wap.dao.ICommonDao;
import com.financing.wap.dto.BaseDTO;
import com.financing.wap.dto.DstArticleCategoriesDTO;
import com.financing.wap.dto.DstArticleDTO;
import com.financing.wap.dto.DstUserSettingDTO;
import com.financing.wap.dto.DstUserVisitLogDTO;
import com.financing.wap.vo.ArticleInfoVO;
import com.financing.wap.vo.DstUserCountInfoVO;
import com.financing.wap.vo.DstUserVisitLogVO;
import com.financing.wap.vo.admin.AdminArticleInfoVO;

import com.financing.wap.vo.admin.AdminUserInfoVO;
import com.financing.wap.vo.admin.AdminUserInvitationVO;
import com.financing.wap.vo.admin.AdminUserVO;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

/***
 * 公用common
 *
 */
@Repository("commonDao")
public class CommonDaoImpl extends BaseDaoImpl<BaseDTO, Integer> implements ICommonDao {


	@Override
	public Class<BaseDTO> getEntityClass() {
		return BaseDTO.class;
	}

	@Override
	public List<DstUserCountInfoVO> querySendDataList(DstUserSettingDTO dto)
			throws SQLException {
		return this.sqlMapClientTemplate.queryForList(SqlName.CommonSql.querySendDataList, dto);
	}

	@Override
	public List<DstUserCountInfoVO> querySendHotArticleList(
			DstUserSettingDTO dto) throws SQLException {
		
		return this.sqlMapClientTemplate.queryForList(SqlName.CommonSql.querySendHotArticleList, dto);
	}

	@Override
	public List<DstUserCountInfoVO> sendSummaryReminderList(
			DstUserSettingDTO dto) throws SQLException {
		return this.sqlMapClientTemplate.queryForList(SqlName.CommonSql.sendSummaryReminderList, dto);
	}

	@Override
	public DstUserCountInfoVO visitDateLog(String openid) throws SQLException {
		return (DstUserCountInfoVO) this.sqlMapClientTemplate.queryForObject(SqlName.CommonSql.visitDateLog, openid);
	}

	@Override
	public List<ArticleInfoVO> visitArticleInfo(String openid)
			throws SQLException {
		return this.sqlMapClientTemplate.queryForList(SqlName.CommonSql.visitArticleInfo, openid);
	}

	@Override
	public List<DstUserVisitLogVO> dstUserVisitLogList(DstUserVisitLogDTO dstUserVisitLog) {
		return this.sqlMapClientTemplate.queryForList(SqlName.CommonSql.dstUserVisitLogList, dstUserVisitLog);
	}

	@Override
	public int dstUserVisitLogListCount(DstUserVisitLogDTO dstUserVisitLog) {
		return (Integer) this.sqlMapClientTemplate.queryForObject(SqlName.CommonSql.dstUserVisitLogListCount, dstUserVisitLog);
	}

	@Override
	public void addVisitArticleLog(DstArticleDTO dto) throws SQLException {
		 this.sqlMapClientTemplate.update(SqlName.CommonSql.addVisitArticleLog, dto);
	}

	@Override
	public List<DstArticleDTO> myAllArticleInfo(DstArticleDTO dstArticle)
			throws SQLException {
		return  this.sqlMapClientTemplate.queryForList(SqlName.CommonSql.myAllArticleInfo, dstArticle);
	}

	@Override
	public int myAllArticleInfoCount(DstArticleDTO dstArticle)
			throws SQLException {
		return  (Integer) this.sqlMapClientTemplate.queryForObject(SqlName.CommonSql.myAllArticleInfoCount, dstArticle);
	}

	@Override
	public int adminArticleInfoCount(AdminArticleInfoVO dstArticle) {
		return (Integer) this.sqlMapClientTemplate.queryForObject(SqlName.CommonSql.adminAllArticleInfoCount, dstArticle);
	}

	@Override
	public List<AdminArticleInfoVO> adminAllArticleInfo(AdminArticleInfoVO dstArticle) {
		return this.sqlMapClientTemplate.queryForList(SqlName.CommonSql.adminAllArticleInfo, dstArticle);
	}

	@Override
	public List<String> dstUserVisitLogGroupDate(DstUserVisitLogDTO dstUserVisitLog) {
		return this.sqlMapClientTemplate.queryForList(SqlName.CommonSql.dstUserVisitLogGroupDate, dstUserVisitLog);
	}

	@Override
	public Map<String,String> queryOperationStatisticsForAll(Map<String, String> papMap) {
		return (Map)this.sqlMapClientTemplate.queryForObject(SqlName.CommonSql.queryOperationStatisticsForAll, papMap);
	}

	@Override
	public List<Map<String, String>> queryOperationStatisticsForDailyDischarge(Map<String, String> papMap) {
		return this.sqlMapClientTemplate.queryForList(SqlName.CommonSql.queryOperationStatisticsForDailyDischarge, papMap);
	}

	@Override
	public List<Map<String, String>> queryOperationStatisticsForDailyDischargeUser(Map<String, String> papMap) {
		return this.sqlMapClientTemplate.queryForList(SqlName.CommonSql.queryOperationStatisticsForDailyDischargeUser, papMap);
	}

	@Override
	public List<Map<String, String>> queryOperationStatisticsForArticleTrend(Map<String, String> papMap) {
		return this.sqlMapClientTemplate.queryForList(SqlName.CommonSql.queryOperationStatisticsForArticleTrend, papMap);
	}

	@Override
	public List<Map<String, String>> queryOperationStatisticsForArticleType(Map<String, String> papMap) {
		return this.sqlMapClientTemplate.queryForList(SqlName.CommonSql.queryOperationStatisticsForArticleType, papMap);
	}

	@Override
	public List<Map<String, String>> listDstUserVisitLogShare(Map<String, String> papMap) {
		return this.sqlMapClientTemplate.queryForList(SqlName.CommonSql.listDstUserVisitLogShare, papMap);
	}

	@Override
	public List<Map<String, Object>> listDstUserVisitLogShareIcon(Map<String, String> papMap) {
		return this.sqlMapClientTemplate.queryForList(SqlName.CommonSql.listDstUserVisitLogShareIcon, papMap);
	}

	@Override
	public List<Map<String, Object>> listDstUserVisitLogIcon(Map<String, String> papMap) {
		return this.sqlMapClientTemplate.queryForList(SqlName.CommonSql.listDstUserVisitLogIcon, papMap);
	}

	@Override
	public void addUserWeeklyTypeZh(Map<String, String> papMap) {
		 this.sqlMapClientTemplate.insert(SqlName.CommonSql.addUserWeeklyTypeZh, papMap);
		 this.sqlMapClientTemplate.insert(SqlName.CommonSql.addUserWeeklyTypeView, papMap);
		this.sqlMapClientTemplate.insert(SqlName.CommonSql.addUserWeeklyTypeWz, papMap);

	}

	@Override
	public void articleRealTimePush(Map<String, String> map) {
		this.sqlMapClientTemplate.insert(SqlName.CommonSql.articleRealTimePush, map);
	}

	@Override
	public int queryUserInfoListCount(AdminUserVO adminUserVO) {
		return (Integer) this.sqlMapClientTemplate.queryForObject(SqlName.CommonSql.queryUserInfoListCount, adminUserVO);
	}

	@Override
	public List<AdminUserVO> queryUserInfoList(AdminUserVO adminUserVO) {
		return this.sqlMapClientTemplate.queryForList(SqlName.CommonSql.queryUserInfoList, adminUserVO);
	}

	@Override
	public AdminUserInfoVO queryUserInfoDetailed(String openid) {
		return (AdminUserInfoVO) this.sqlMapClientTemplate.queryForObject(SqlName.CommonSql.queryUserInfoDetailed, openid);
	}

	@Override
	public List<AdminUserInvitationVO> adminUserInvitationList(String openid) {
		return this.sqlMapClientTemplate.queryForList(SqlName.CommonSql.adminUserInvitationList, openid);
	}

	@Override
	public int allArticleTypeInfoCount(DstArticleCategoriesDTO dto) {
		return  (Integer) this.sqlMapClientTemplate.queryForObject(SqlName.CommonSql.allArticleTypeInfoCount,dto);
	}

	@Override
	public List<DstArticleCategoriesDTO> allArticleTypeInfo(DstArticleCategoriesDTO dto) {
		return this.sqlMapClientTemplate.queryForList(SqlName.CommonSql.allArticleTypeInfo,dto);
	}
}
